package com.br4mmie.asciistory.mission;

import java.io.BufferedReader;
import java.io.IOException;

import com.br4mmie.asciistory.CharImage;
import com.br4mmie.asciistory.mission.Item;


/**
 * @author Ken Veenstra
 * items met extra's of voor quests
 * word half gebruikt, nuttig voor uitbreiding
 */

public class RemainingItems extends Item
{
	private String extra;

	public RemainingItems( String name, String description, String extra, CharImage itemImage, int gold, String type ) 
	{
		super( name, description, itemImage, gold, type );
		this.extra = extra;
	}
	
	public String getExtra()
	{
		return extra;		//what does the item do! how to use BRAMM!!
	}

	public static RemainingItems fromFile(String line, BufferedReader file) throws IOException 
	{
		String name = line.substring(2);	// name
		String z = null;					// description
		String e = null;					// extra
		CharImage i = null;					// charimage
		int g = 0;							// gold
		String t = null;
		
		while(true)
		{
			line = file.readLine();
			if(line == null) break;
			
			if(line.startsWith("e "))
			{
				e = line.substring(2);
			}
			else if(line.startsWith("z "))
			{
				z = line.substring(2);
			}
			else if(line.startsWith("i "))
			{
				i = new CharImage(1, 1);
				i.setImage(line.substring(2));
			}
			else if(line.startsWith("g "))
			{
				g = Integer.parseInt(line.substring(2));
			}
			else if(line.startsWith("t "));
			{
				t = line.substring(2);
			}
		}
		
		return new RemainingItems(name, z, e, i, g, t);
	}

}

